package com.blog.cmrpersonalblog.enums;

import lombok.Getter;

/**
 * 榜单维度枚举
 */
@Getter
public enum RankingDimension {
    
    /**
     * 综合榜单（全站）
     */
    OVERALL("OVERALL", "综合榜", null, "全站综合排行"),
    
    /**
     * 按分类的榜单
     */
    CATEGORY("CATEGORY", "分类榜", "categoryId", "按文章分类的排行");
    
    /**
     * 维度代码
     */
    private final String code;
    
    /**
     * 维度名称
     */
    private final String name;
    
    /**
     * 维度参数名称
     */
    private final String paramName;
    
    /**
     * 维度描述
     */
    private final String description;
    
    RankingDimension(String code, String name, String paramName, String description) {
        this.code = code;
        this.name = name;
        this.paramName = paramName;
        this.description = description;
    }
    
    /**
     * 根据代码获取枚举
     */
    public static RankingDimension fromCode(String code) {
        for (RankingDimension dimension : values()) {
            if (dimension.getCode().equals(code)) {
                return dimension;
            }
        }
        throw new IllegalArgumentException("未知的榜单维度: " + code);
    }
}

